import { CategoryResult } from "@/types/category";
import { PageParams, PageResult } from "@/types/common";
import request from "@/utils/request";

/**
 * 分类分页查询
 * @param params 
 * @returns 
 */
export const getAdminCategoryPageAPI = (params: PageParams & { name?: string, type?: number }) => {
  return request<PageResult<CategoryResult[]>>({
    method: 'GET',
    url: '/admin/category/page',
    params
  })
}
/**
 * 启用、禁用分类
 * @param status 
 * @param id 
 * @returns 
 */
export const postAdminCategoryStatusAPI = (status: number, id: number) => {
  return request({
    method: 'POST',
    url: `/admin/category/status/${status}`,
    params: { id }
  })
}
/**
 * 根据id查询分类
 * @param id 
 * @returns 
 */
export const getAdminCategoryAPI = (id: number) => {
  return request({
    method: 'GET',
    url: `/admin/category/${id}`
  })
}
/**
 * 根据类型查询分类
 * @param type 
 * @returns 
 */
export const getAdminCategoryByTypeAPI = (type?: number) => {
  return request({
    method: 'GET',
    url: '/admin/category/list',
    params: { type }
  })
}